package com.daisuxia.web.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.daisuxia.web.pojo.AppVersion;
import com.daisuxia.web.service.IAppVersionService;

@Controller
@RequestMapping("version/")
public class VersionController {

	@Autowired
	private IAppVersionService appVersionService;
	
	@RequestMapping("getCurrentVersion/")
	@ResponseBody
	public AppVersion  getCurrentVersion(HttpServletRequest request) {
		Map<String,String> param = new HashMap<String,String	>();
		String clientType = request.getParameter("clientType");
		String version = request.getParameter("version");
		if("android".equals(clientType)) 
			param.put("OS", "Android");
		else
			param.put("OS", "IOS");
		param.put("version", version);
		AppVersion appVersion = appVersionService.getCurrentVersion(param);
		return appVersion;
	}
	
}
